import Ajax from './ajax'
import mockAjax from './mockAjax'

//三级分类列表获取请求数据
export const reqCategoryList = function () {
    return Ajax({
        url: '/product/getBaseCategoryList',
        method: 'get'
    })
}
//mock模拟ListContainer组件轮播图的数据
export const reqBannerList = () => {
    return mockAjax({
        url: '/banner',
        method: 'get'
    })
}
//mock模拟Floor组件中轮播图的数据
export const reqFloorList = () => {
    return mockAjax({
        url: '/floor',
        method: 'get'
    })
}

//获取search页面商品数据
export const reqGoodsListInfo = (requestOptions) => {
    return Ajax({
        url: '/list',
        method: 'post',
        data: requestOptions
    })
}

//获取商品详情
export const reqGoodsDetailInfo = (skuId) => {
    return Ajax({
        url: `/item/${skuId}`,
        method: 'get'
    })
}

//添加购物车或更改购物车单个数量
export const reqAddOrUpdateShoppingCart = (skuId, skuNum) => {
    return Ajax({
        url: `/cart/addToCart/${skuId}/${skuNum}`,
        method: 'post'
    })
}

//获取购物车列表
export const reqShoppingCartList = () => {
    return Ajax({
        url: '/cart/cartList',
        method: 'get'
    })
}

//修改购物车选中状态
export const reqUpdateShoppingCartCheckedOne = (skuId, isChecked) => {
    return Ajax({
        url: `/cart/checkCart/${skuId}/${isChecked}`,
        method: 'get'
    })
}

//批量修改购物车状态
export const reqUpdateShoppingCartCheckedAll = (isChecked, skuIds) => {
    return Ajax({
        url: `/cart/batchCheckCart/${isChecked}`,
        method: 'post',
        data: skuIds
    })
}

//删除一个商品
export const reqDeleteShoppingCartOne = (skuId) => {
    return Ajax({
        url: `/cart/deleteCart/${skuId}`,
        method: 'delete'
    })
}

//删除所有选中商品
export const reqDeleteShoppingCartAllChecked = (skuIds) => {
    return Ajax({
        url: `/cart/batchDeleteCart`,
        method: 'delete',
        data: skuIds
    })
}

//获取注册验证码
export const reqGetCode = (phone) => {
    return Ajax({
        url: `/user/passport/sendCode/${phone}`,
        method: 'get'
    })
}


//用户注册
export const reqUserRegister = (userInfo) => {
    return Ajax({
        url: "/user/passport/register",
        method: 'post',
        data: userInfo
    })
}

//用户登录
export const reqUserLogin = (userInfo) => {
    return Ajax({
        url: '/user/passport/login',
        method: 'post',
        data: userInfo
    })
}

//获取用户信息
export const reqGetUserInfo = () => {
    return Ajax({
        url: "/user/passport/auth/getUserInfo",
        method: 'get'
    })
}

//退出登录
export const reqUserLogout = () => {
    return Ajax({
        url: "/user/passport/logout",
        method: 'get'
    })
}

//获取用户收货地址信息
export const reqGetUserAdressList = () => {
    return Ajax({
        url: "/user/userAddress/auth/findUserAddressList",
        method: 'get'
    })
}

//获取订单交易页信息
export const reqGetTradeInfo = () => {
    return Ajax({
        url: '/order/auth/trade',
        method: 'get'
    })
}

//提交订单,获取订单编号
export const reqSubmitOrder = (tradeNo, tradeInfo) => {
    return Ajax({
        url: `/order/auth/submitOrder?tradeNo=${tradeNo}`,
        method: 'post',
        data: tradeInfo
    })
}

//获取订单支付信息
export const reqGetPayInfo = (orderId) => {
    return Ajax({
        url: `/payment/weixin/createNative/${orderId}`,
        method: 'get'
    })
}

//查询订单支付状态
export const reqQueryPayStatus = (orderId) => {
    return Ajax({
        url: `/payment/weixin/queryPayStatus/${orderId}`,
        method: 'get'
    })
}

//获取我的订单列表
export const reqGetMyOrderInfo=(page,limit)=>{
    return Ajax({
        url:`/order/auth/${page}/${limit}`,
        method:'get'
    })
}